﻿@model Isaac.Joy.Identity.Web.DtCms.Models.UserPwdModel
@{
    ViewBag.Title = "修改个人密码";
    Layout = Url.BundleContent("~/Views/Shared/_Layout.cshtml");
}
<div id="mainform">
    <!--导航栏-->
    <div class="location">
        <a href="javascript:history.back(-1);" class="back"><i></i><span>返回上一页</span></a>
        <a class="home"><i></i><span>控制面板</span></a>
        <i class="arrow"></i>
        <span>修改个人密码</span>
    </div>
    <div class="line10"></div>
    <!--/导航栏-->
    <!--内容-->
    <div class="content-tab-wrap">
        <div id="floatHead" class="content-tab">
            <div class="content-tab-ul-wrap">
                <ul>
                    <li><a href="javascript:;" onclick="tabs(this);" class="selected">修改个人密码</a></li>
                </ul>
            </div>
        </div>
    </div>
    <div class="tab-content">
        <dl>
            <dt>用户名</dt>
            <dd>
                <input type="text" id="txtAccount" class="input normal" disabled="disabled" datatype="*2-200" sucmsg=" " value="@Model.Account" />
            </dd>
        </dl>
        <dl>
            <dt>原密码</dt>
            <dd>
                <input type="password" id="txtOldPassword" class="input normal" datatype="*6-20" nullmsg="请设置密码" errormsg="密码范围在6-20位之间" sucmsg=" " />
                <span class="Validform_checktip">*登录的密码，至少6位</span></dd>
        </dl>
        <dl>
            <dt>新密码</dt>
            <dd>
                <input type="password" id="txtPassword" name="txtPassword" class="input normal" datatype="*6-20" nullmsg="请设置密码" errormsg="密码范围在6-20位之间" sucmsg=" " />
                <span class="Validform_checktip">*登录的密码，至少6位</span></dd>
        </dl>
        <dl>
            <dt>确认密码</dt>
            <dd>
                <input type="password" id="txtPassword2" class="input normal" datatype="*" recheck="txtPassword" nullmsg="请再输入一次密码" errormsg="两次输入的密码不一致" sucmsg=" " />
                <span class="Validform_checktip">*再次输入密码</span></dd>
        </dl>
    </div>
    <!--/内容-->

    <!--工具栏-->
    <div class="page-footer">
        <div class="btn-list">
            <input type="button" value="提交保存" id="btnSubmit" class="btn" />
            @*<input name="btnReturn" type="button" value="返回上一页" class="btn yellow" onclick="javascript: history.back(-1);" />*@
        </div>
        <div class="clear"></div>
    </div>
    <!--/工具栏-->
</div>

@section scripts{
    <script type="text/javascript">
        $(function () {
            var mainform = $("#mainform").Validform({ tiptype: dtcmstiptype, showAllError: true });

            $("#btnSubmit").click(function () {
                if (!mainform.check()) return false;

                $.ajax({
                    url: '@Url.Action("AjaxPwd")',
                    type: "post",
                    data: "Account=" + $("#txtAccount").val() +
                        "&OldPassword=" + $("#txtOldPassword").val() +
                        "&Password=" + $("#txtPassword").val() +
                        "",
                    processData: false,
                    success: function (response) {
                        var data = JSON.parse(response);
                        errorCode.getMsg(data, function () {
                            if (data.success) {
                                $.dialog.alert('添加成功！', function () {
                                    document.location.reload();
                                }, null, "提示");
                            } else {
                                $.dialog.alert('添加失败！');
                            }
                        }, function (e) {
                            $.dialog.alert(data.msg == '' ? e.msg : data.msg);
                        });
                        return false;
                    }
                });
                return false;
            });
        });
    </script>
}